<template>
	<view>
		<view class="title">答题卡</view>
		<scroll-view scroll-y="true" class="list">
			<view class="menu-list">
				<uv-grid :border="false" :col="4" align="left">
					<uv-grid-item :customStyle="{width:170+'rpx',height:160+'rpx'}" v-for="(item, index) in list" :key="index"
						@click="menuClick(index)">
						<view class="circle-btn" :class="[curIndex == item.index-1 ? 'current' : (!isEmpty(item) ? 'done' : 'undo')]"
							:key="item.index">{{item.index + 1}}</view>
					</uv-grid-item>
				</uv-grid>
			</view>
		</scroll-view>
		<view class="tip-view">
			<view class="circle-btn done">已做</view>
			<view class="circle-btn current">当前</view>
			<view class="circle-btn undo">未做</view>
		</view>
		<view v-if="isAnalyse == 2">
			<button class="handle-btn" @click="handlePaper">交卷</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
          doneTimu:[],
					undoTimu:[]
			};
		},
		props: {
			curIndex: {
				type: Number,
				default: 0
			},
			isAnalyse: {
				type: Number,
				default: 0
			},
			list: {
				type: Array,
				default: []
			},
		},
		mounted() {
			console.log('timucard ', this.list);
		},
		methods: {
			isEmpty(item) {
				const empty = item.inputNum.every((obj) => {
					return Object.keys(obj).length === 0;
				});
				return empty;
			},
			getBtnCls(item, index) {
				return item.done ? 'done' : 'undo'
			},
			menuClick(index) {
				this.$emit('menuClick', index);
			},
			chooseTimu(index) {
				this.$emit('choose', index);
			},
			handlePaper(){
				this.list.forEach(item =>{
					item.inputNum.every((obj) => {
						if(Object.keys(obj).length === 0){
							this.undoTimu.push(item.index);
						}else{
							this.doneTimu.push(item.index);		
						}
					});
				})
			  this.$emit('handlePaper', {undoTimu:this.undoTimu,doneTimu:this.doneTimu});
			}
		}
	}
</script>

<style>
	.content {
		background-color: #ffffff;
	}

	.title {
		width: 100%;
		height: 80rpx;
		line-height: 80rpx;
		color: #333333;
		font-size: 36rpx;
		text-align: center;
	}

	.list {
		width: 100%;
		height: 530rpx;
		align-items: center;
	}

	.row {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
	}

	.circle-btn {
		justify-content: center;
		align-items: center;
		width: 80rpx;
		height: 80rpx;
		font-size: 28rpx;
		line-height: 80rpx;
		text-align: center;
		border-radius: 50rpx;
		margin: 20rpx;
		background-color: #ffffff;
		color: #000000;
	}

	.tip-view {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
	}

	.done {
		color: #ffffff;
		background-color: #29B581;
	}

	.current {
		color: #ffffff;
		background-color: #ed675a;
	}

	.undo {
		border-color: #999999;
		border-width: 1rpx;
		border-style: solid;
	}

	.handle-btn {
		width: 90%;
		height: 80rpx;
		line-height: 80rpx;
		color: #ffffff;
		background-color: #29B581;
		border-radius: 10rpx;
		margin-left: 5%;
		text-align: center;
	}

	.menu-list {
		width: 690rpx;
		margin-left: 30rpx;
		background-color: #ffffff;
		padding-top: 20rpx;
		padding-bottom: 20rpx;
	}
</style>